﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Chinook.Core
{
   public class LogData
    {
       public string ClassName { get; set; }
       public string MethodName { get; set; }
       public string Message { get; set; }
       public Double ExecutionTime { get; set; }
       public long  TimeStamp { get; set; }
       public DateTime ExecutionDateAndTime
       {
           get
           {
               return ConvertFromUnixTimestamp(this.TimeStamp);
           }
       }
       #region DateTime

       static DateTime ConvertFromUnixTimestamp(long unixTimeStamp)
       {
           return (new DateTime(1970, 1, 1, 0, 0, 0,DateTimeKind.Local)).AddSeconds(unixTimeStamp);
       }


       static double ConvertToUnixTimestamp(DateTime date)
       {
           DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
           TimeSpan diff = date - origin;
           return Math.Floor(diff.TotalSeconds);
       }
       #endregion DateTime
    }
}
